package com.example.wssapp.view;

import android.annotation.SuppressLint;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.LinearGradient;
import android.graphics.Paint;
import android.graphics.Shader.TileMode;
import android.util.AttributeSet;
import android.view.View;

public class RectView extends View {
	
	private Paint paint;

	public RectView(Context context) {
		super(context);
	}
	
	public RectView(Context context, AttributeSet attributeSet, int defStyle) {
		super(context, attributeSet, defStyle);
	}
	
	public RectView(Context context, AttributeSet attributeSet) {
		super(context, attributeSet);
	}
	
	@SuppressLint("DrawAllocation")
	@Override
	protected void onDraw(Canvas canvas) {
		super.onDraw(canvas);
		
		paint = new Paint();
		paint.setColor(Color.GREEN);
		paint.setStrokeWidth(1f);
		paint.setStyle(Paint.Style.FILL_AND_STROKE);
		LinearGradient lg = new LinearGradient(0f, 0f, 115f, 115f, Color.GREEN, Color.YELLOW, TileMode.CLAMP);
		paint.setShader(lg);
		
		canvas.drawRect(10, 10, 300, 200, paint);
		invalidate();
	}

}
